/**
 * 2000-2012 be2bill & Quadra informatique
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0) that is available
 * through the world-wide-web at this URL: http://www.opensource.org/licenses/OSL-3.0
 * If you are unable to obtain it through the world-wide-web, please contact us
 * to ecommerce@quadra-informatique.fr so we can send you a copy immediately.
 *
 * @author Quadra Informatique <ecommerce@quadra-informatique.fr>
 * @author XL CROISSANCE NET <contact@croissance-net.com>
 * @copyright 2000-2012 be2bill & Quadra informatique
 * @version Release: $Revision: 1.0.0 $
 * @license http://www.opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

$(document).ready(function() {
    // Set dynamically the redirectino link of the oneclick button
    if($('input#be2bill_set_create_alias').length > 0) {
		
        $('.be2bill_link').attr('href', $('.be2bill_link').attr('href').substring(0, $('.be2bill_link').attr('href').length-1)+(($('input#be2bill_set_create_alias').is(':checked')) == true?'1':'0'));
        $('input#be2bill_set_create_alias').bind('click', function(e){
			console.log($('input#be2bill_set_create_alias').attr('checked'));
            $('.be2bill_link').attr('href', $('.be2bill_link').attr('href').substring(0, $('.be2bill_link').attr('href').length-1)+($('input#be2bill_set_create_alias').attr('checked') == 'checked'?'1':'0'));
        });
    }

    // Active the button action only if the CVV is not empty
    if($('input#be2bill_cvv_setter').length > 0)
        $('div#be2bill-payment-oneclick a').bind('click', function(e){
            e.preventDefault();
            if($('input#be2bill_cvv_setter').val().length >=3)
                $('form#form_cvv').submit();
        });
});
